﻿#region 命名空间

using System;
using System.Text;

#endregion

namespace Sharp.Infrastructure.Security
{
    /// <summary>
    ///     Base64 函数
    /// </summary>
    public class Base64Encrypt
    {
        /// <summary>
        ///     转换到Base64
        /// </summary>
        /// <param name="psClearString"></param>
        /// <returns></returns>
        public static string ToBase64(string psClearString)
        {
            byte[] data = Encoding.UTF8.GetBytes(psClearString);
            return Convert.ToBase64String(data);
        }

        /// <summary>
        ///     从Base64还原
        /// </summary>
        /// <param name="ps64String"></param>
        /// <returns></returns>
        public static string FromBase64(string ps64String)
        {
            byte[] data = Convert.FromBase64String(ps64String);
            return Encoding.UTF8.GetString(data);
        }
    }
}